package com.battle.service.controller.web;

import com.battle.pojo.param.searchRecord.*;
import com.battle.pojo.vo.searchRecord.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/搜索记录
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/searchRecord/web")
public class SearchRecordWebController {

    private final SearchRecordService service;

    public SearchRecordWebController(SearchRecordService service) {
        this.service = service;
    }


    /**
     * 创建搜索记录
     *
     * @param param
     * @return
     */
    @PostMapping("/createSearchRecord")
    public ApiResult createSearchRecord(@RequestBody @Valid CreateSearchRecordParam param) {
        service.createSearchRecord(param);
        return ApiResult.ok();
    }


    /**
     * 移除搜索记录
     *
     * @param id
     */
    @DeleteMapping("/removeSearchRecord")
    public ApiResult removeSearchRecord(@RequestParam("id") Long id) {
        service.removeSearchRecord(id);
        return ApiResult.ok();
    }

    /**
     * 获取搜索记录下拉列表
     *
     * @return
     */
    @PostMapping("/getSearchRecordDownList")
    public ApiResult<List<GetSearchRecordDownListVo>> getSearchRecordDownList(@RequestBody(required = false) @Valid GetSearchRecordDownListParam param) {
        List<GetSearchRecordDownListVo> list = service.getSearchRecordDownList(param);
        return ApiResult.ok(list);
    }


}

